﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Agresso.Interface.Layer.SQL
{
    public class MaxPostInvoiceSQL
    {
        public static string InsertMaxPostInvoice()
        {
            return @"
INSERT INTO [AGRWIN_DEV].[dbo].[i_maxpostinvoice]
           ([insert_date]
           ,[pickup_date]
           ,[update_date]
           ,[pickup_flag]
           ,[DocumentType]
           ,[DocumentDate]
           ,[PostingDate]
           ,[InvoiceIndicator]
           ,[ObjectType]
           ,[ReferenceDocumentNumber]
           ,[CompanyCode]
           ,[VendorID]
           ,[PurchaseOrderNumber]
           ,[Currency]
           ,[GrossAmount]
           ,[NetAmount]
           ,[BaselineDate]
           ,[HeaderText]
           ,[DeliveryCosts]
           ,[ReceiverName1]
           ,[ReceiverPOCode]
           ,[ReceiverCity]
           ,[ReceiverHousenumber]
           ,[Name1]
           ,[BankAccountNumber]
           ,[BankNumber]
           ,[TaxNumber1]
           ,[VatRegistrationNumber]
           ,[BankAccountNumber_]
           ,[BankNumber_]
           ,[TaxPercentage]
           ,[TaxAmount]
           ,[PurchaseOrderNumber_]
           ,[PurchaseOrderItem]
           ,[ItemAmount]
           ,[ItemDiscount]
           ,[Quantity]
           ,[ItemVendorNumber]
           ,[ItemText]
            ,[FileName]
            )
     VALUES
           (getdate()
           ,getdate()
           ,getdate()
           ,'0'
           ,@DocumentType
           ,@DocumentDate
           ,@PostingDate
           ,@InvoiceIndicator
           ,@ObjectType
           ,@ReferenceDocumentNumber
           ,@CompanyCode
           ,@VendorID
           ,@PurchaseOrderNumber
           ,@Currency
           ,@GrossAmount
           ,@NetAmount
           ,@BaselineDate
           ,@HeaderText
           ,@DeliveryCosts
           ,@ReceiverName1
           ,@ReceiverPOCode
           ,@ReceiverCity
           ,@ReceiverHousenumber
           ,@Name1
           ,@BankAccountNumber
           ,@BankNumber
           ,@TaxNumber1
           ,@VatRegistrationNumber
           ,@BankAccountNumber_
           ,@BankNumber_
           ,@TaxPercentage
           ,@TaxAmount
           ,@PurchaseOrderNumber_
           ,@PurchaseOrderItem
           ,@ItemAmount
           ,@ItemDiscount
           ,@Quantity
           ,@ItemVendorNumber
           ,@ItemText
            ,@FileName
)
";
        }

        public static string SelectAllPendingInfoice()
        {
            return @"select distinct FileName from i_maxpostinvoice where pickup_flag = '0'";
        }

        public static string SelectAllPendingInfoiceByFilename()
        {
            return @"select * from i_maxpostinvoice where pickup_flag = '0' and FileName=@FileName";
        }

        public static string UpdateMaxPostInvoiceStatus()
        {
            return @"update i_maxpostinvoice set pickup_flag=@pickup_flag, update_date=getdate(), 
            batch_id=@batch_id, remark=@remark where i_maxpostinvoice_id = @i_maxpostinvoice_id";
        }
    }
}
